﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace OpenST.Tiles
{
    class RandomColorTile : BaseTile
    {
        public RandomColorTile(ContentManager content)
            : base(content)
        {
            Sprite = content.Load<Texture2D>("Tiles/TileRand");
            GetsSaved = true;


            // By default, It will pick any note (1-12)
            List<int> colors = new List<int>();
            for (int i = 0; i < 12; i++)
            {
                colors.Add(i);
            }


            TileData.Add("Colors", colors);


        }

        public override void Process(Bug bug)
        {
            // Normal tile just plays the audio
            bug.PlaySound(NoteNumber);
            //base.Process(bug);
        }

        public override void Update(GameTime gameTime)
        {
            //given some Guide
            Guid guid = Guid.NewGuid();
            //extract an integer from the beginning of the Guid
            byte[] _bytes = guid.ToByteArray();
            int i = ((int)_bytes[0]) | ((int)_bytes[1] << 8) | ((int)_bytes[2] << 16) | ((int)_bytes[3] << 24);

            Random random = new Random(i);
            List<int> Colors;
            Colors = (List<int>)TileData["Colors"];

            NoteNumber = Colors[random.Next(Colors.Count)];
            
            //base.Update(gameTime);
        }
    }
}
